<!--
/**
* @author xuyh0817
* @email xuyh0817@foxmail.com
* @date 2022-03-27 23:00
* @version 2.0.0
* @doc todo
* @website todo
* @remark  如果要分发源码，需在本文件顶部保留此文件头信息！！
*/
-->
<template>
  <a-modal
    title="预览"
    :visible="visible"
    :footer="null"
    width="90%"
    @cancel="$emit('update:visible',false)"
  >
    <x-render-table
      :columns="xDesignTable.tableColumnOptions"
      :data-source="dataSource"
      :table-props="xDesignTable.tablePropsData"
      :table-btns="xDesignTable.tableBtns"
    />
  </a-modal>
</template>

<script>
export default {
  name: 'XRenderPreviewDialog',
  inject: ['xDesignTable'],
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      dataSource: []
    }
  },
  watch: {
    visible: {
      immediate: true,
      handler(val) {
        if (val) {
          this.getDataSource()
        }
      }
    }
  },
  methods: {
    getDataSource() {
      const { dataSource, xDesignTable } = this
      dataSource.splice(0, dataSource.length, ...xDesignTable.dataSource)
    }
  }
}
</script>
